home *** CD-ROM | disk | FTP | other *** search
- Path: in2.uu.net!interaccess!pbrianmcg
- From: brianmcg@interaccess.com (Brian V. McGroarty)
- Newsgroups: comp.lang.c
- Subject: Re: Writing A Pointer To Memory
- Date: 20 Mar 1996 03:07:52 GMT
- Organization: InterAccess, Chicago's best Internet Service Provider
- Message-ID: <4insq8$99t@nntp.interaccess.com>
- NNTP-Posting-Host: d54-isdn.nhe.interaccess.com
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- MS-DOS 16-bit mode "far" pointers aren't entirely safe for pointer
- arithmetic. In some modes, MS-DOS compilers will wrap through a 64k segment
- when performing pointer arithmetic. You will need a "huge" pointer, which
- can be used for pointer arithmetic through the entire range of low memory.
-
-
- Try:
-
- void far *ptr = far pointer to a structure;
-
- void huge *desiredDestinationPtr;
- desiredDestinationPtr = ((void huge *)locationPtr) - sizeof(void far *);
-
- Note that more pedantic compiler modes will require that you recast the void
- pointer to another data type pointer before you can perform arithmetic on it,
- claiming that "void" has no size.
-
-
- Nathan T. Wild wrote:
-
- [...]
-
- > the location in RAM that I have to write to is
- > 2xsizeof(far *) or 8 bytes back from a specific
- > location in memory.
-
- > I know where I need to write the pointer, and what I
- > need to write, but for some strange reason I cannot get
- > it to do what I want...
-
- >take:
-
- >void far *ptr = far pointer to a structure;
-
- > desiredDestinationPtr = (locationPtr - sizeof(void far *));
-
- [...]
-
- > Please respond via email asap...
-
- Copied.
-
-
-
- ---
- Brian Valters McGroarty -- brianmcg@bix.com
- phone/fax (847) 439-7714
-
-
-
-
-
-